﻿namespace Monadic.Tests
{
    using System;
    using System.Text;
    using System.Collections.Generic;
    using System.Linq;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    
    [TestClass]
    public class ContinuationTests
    {

        public static Continuation<R, int> Square<R>(int x)
        {
            return Continuation.Create<R, int>(() => x * x);
        }

        public static Continuation<R, double> Hypotoneuse<R>(int x, int y)
        {
            return from h in Square<R>(x)
                   from w in Square<R>(y)
                   select Math.Sqrt(h + w);
        }

        [TestMethod]
        public void ContinuationTest()
        {
            Assert.AreEqual(5, Hypotoneuse<double>(3, 4).Run(n => n));
        }

        [TestMethod]
        public void TestMethod2()
        {
            var square = Continuation.Create<int, int>(x => x * x);
            
            var hypotoneuse = from h in square
                              from w in square
                              select Math.Sqrt(h + w);

            //Assert.AreEqual(5, hypotoneuse<double>(3, 4).Run(n => n));
        }
    }
}
